<?php

class dns extends seo_engine
{
	const PLUGIN_NAME 			= 'DNS';
	const PLUGIN_DESCRIPTION 	= "Dns checking"; 
	const NAME_CACHE 			= 'plugin_dns';
	const ICON 					= '';


	public function get_records( $domain_root )
	{
		$stats['records'] = dns_get_record($domain_root);
		var_dump($stats);
		return $stats;
	}

	public function get_template( $action = false )
	{
		// safety, prevent other cases
		if(!is_numeric($action))
			$action = 0;


		switch($action)
		{
			case 0:
				$t = "<form method='GET'>
					<input type='hidden' name='page' value='".get_class($this)."' />
					<input type='hidden' name='action' value='1' />
					<input type='text' name='url' value='http://'>
					<input type='submit' value='Submit'/>
				</form>";
			break;

			case 1:
				//global $seo;
				// make sure that url was submitted
				if(!isset($_GET['url']))
				{
					$t = "Error, no domain was received";
					break;
				}
				
				$url = $_GET['url'];
				if( !$this->trimt_to_root($url) )
				{ 	
					$t = "Error, not a valid url inserted!";
					break;
				}

				// save domain root
				$domain_root 	= $this->trimt_to_root($url);
				$stats 			= $this->get_records($domain_root);
					
				var_dump($stats);			

				$t = "<table border=1px><tr>
					  <th>DNS Records</th></tr>
					  <tr><td>".$stats['records']."</td> 
					  </tr></table>";
			break;

			default:
				$t = "Page doesn't exist";
		}

		return $t;
	}
}

?>